package com.fwtai.api.controller;

import com.fwtai.config.ConfigFile;
import com.fwtai.entity.ReqPage;
import com.fwtai.service.api.ApiProductShowService;
import com.fwtai.tool.ToolClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 产品展示控制层|路由层[api]
 * @作者 田应平
 * @版本 v1.0
 * @QQ号码 444141300
 * @Email service@fwtai.com
 * @创建日期 2024-02-06 19:31:40
 * @官网 <url>http://www.fwtai.com</url>
*/
@RestController
@Api(tags = "产品展示",description = "token选填")
@RequestMapping(ConfigFile.guest_v10 +"productShow")
public class ProductShowController{

  private final ApiProductShowService apiProductShowService;

  public ProductShowController(final ApiProductShowService apiProductShowService){
    this.apiProductShowService = apiProductShowService;
  }

  /**根据主键kid查询对应的数据*/
  @ApiOperation(value = "获取单条的产品展示详细信息", notes = "通过主键kid获取产品展示详细信息")
  @ApiImplicitParam(name = "id", value = "被查看的kid", dataType = "String", paramType = "query", required = true)
  @GetMapping("/queryById")
  public void queryById(final Long id,final HttpServletResponse response){
    ToolClient.responseJson(apiProductShowService.queryById(id),response);
  }

  /**获取分页数据,请勿删除ReqPage否则swagger不显示参数*/
  @ApiOperation(value = "获取产品展示分页数据,默认仅含数据不含总记录数总条数", notes = "其参数是搜索过滤条件;排序的key为column值为返回的字段，排序关键字的key为order,其值可选正序ASC|倒序DESC<br/>注意调用端需要判断每次请求返回的条数是否小于每页大小或返回的code=201而停止下一次请求")
  @GetMapping("/listDataPage")
  @ApiImplicitParams({
    @ApiImplicitParam(name = "title", value = "标题（产品名称）", dataType = "String", paramType = "query", required = false),
  })
  public void listDataPage(final ReqPage reqPage,final HttpServletRequest request,final HttpServletResponse response){
    ToolClient.responseJson(apiProductShowService.listData(request),response);
  }
}